package com.example._01helloword.config;

import com.example._01helloword.filter.MyFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

//配置过滤器，执行哪些过滤器，哪些先执行等
@Configuration//指明当前为配置类
public class WebConfiguration {
    @Bean
    public FilterRegistrationBean testFilterRegistration() {
        //注册过滤器对象
        FilterRegistrationBean registration = new FilterRegistrationBean();
        //创建过滤器对象（MyFilter）
        registration.setFilter(new MyFilter());
        //过滤范围
        registration.addUrlPatterns("/*");
        //设置过滤器名字
        registration.setName("MyFilter");
        //多个过滤器时，先后次序
        registration.setOrder(6);
        return registration;
    }
}
